package com.varton;

import com.varton.session.MySqlSession;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MapperProxy<T> implements InvocationHandler{
    private final MySqlSession mySqlSession;
    private final Class<T> mapperClass;
    public MapperProxy(MySqlSession mySqlSession, Class<T> mapperClass) {
        this.mySqlSession = mySqlSession;
        this.mapperClass = mapperClass;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        String id = method.getName();
        String statment = mySqlSession.lookUpSql(id);
        return mySqlSession.selectOne(statment,args);
    }
}
